<!DOCTYPE html>
<html lang="en" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"
      xmlns:th="http://www.thymeleaf.org" >
<header th:fragment="header(title,keywords)">
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"/>
    <meta name="renderer" content="webkit"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-transform"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="shortcut icon" th:href="@{/user/img/bloglogo.jpg}"/>
    <link rel="apple-touch-icon" th:href="@{/user/img/apple-touch-icon.png}"/>
    <title><th:block th:text="${title ?: '首页'}"></th:block></title>
    <link th:href="@{/user/css/xcode.min.css}" rel="stylesheet"/>
    <link th:href="@{/user/css/style.min.css}" rel="stylesheet"/>
    <script th:src="@{/assets/js/jquery.min.js}"></script>
    <script th:src="@{/assets/js/amazeui.min.js}"></script>
    <link rel="stylesheet" th:href="@{/assets/css/amazeui.min.css}"/>
    <link rel="stylesheet" th:href="@{/assets/css/app.css}"/>
    <!--[if lt IE 9]>
    <script th:src="@{/back/js/html5shiv.js}"></script>
    <script th:src="@{/back/js/respond.min.js}"></script>
    <![endif]-->
</header>

<div th:fragment="header-body" id="header" class="header bg-white">
    <div class="navbar-container">
        <a th:href="@{/}" class="navbar-logo">CrazyStone个人博客小站</a>
        <div class="navbar-menu">
    <form name="logoutform" th:action="@{/logout}" method="post"></form>
    <span sec:authorize="isAnonymous()">
        <a class="header-info" th:href="@{/login}">登录</a>
        <a class="header-info" th:href="@{/regist}">注册</a>
    </span>

    <span sec:authorize="isAuthenticated()">
        <span class="header-info" sec:authentication="principal.username"></span>
        <a class="header-info" href="javascript:document.logoutform.submit();">退出</a>
    </span>
    <a class="header-info" href="/admin">后台管理</a>
</div>

        <div class="navbar-search" >
            <span class="icon-search" onclick="search()"></span>
            <form id="searchForm" role="search"  th:action="@{/search}"><!-- onsubmit="return false;" -->
                <span class="search-box">
                    <input type="text" id="search-inp" name="titleKey" class="input" th:placeholder="${keywords ?: '搜索...'}" maxlength="30"
                           autocomplete="off"/>
                </span>
            </form>
        </div>
    </div>
    <script type="text/javascript">
        function search(){
            var title = $('#search-inp').val();
            //alert(title);
            //window.location.href='/search/'+title;
            $("#searchForm").submit();
        }
    </script>
</div>

</html>